
var xmlHttp;
function getGiftFromServer() {
	
	var url = "ajaxCommon.pai?init=" + init + "&hot=" + hot + "&type=all";
	//alert(url);
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}

	xmlHttp.onreadystatechange = showGift;
	
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
	// 1分钟刷新一次
	setTimeout("getGiftFromServer()",60*1000);
}
function showGift() {
	//alert(xmlHttp.responseText);
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		document.getElementById("cate01").innerHTML = xmlHttp.responseText + "<div class='spacer'></div>";
	}
}
// 每秒刷新一下 价格 和当前出价人
var xmlHttpmin;
function getGiftFromServermin() {
	
	//alert("getGiftFromServermin");
	var url = "ajaxCommon.pai?init=" + init + "&hot=" + hot + "&type=time";
	//alert(url);
	if (window.ActiveXObject) {
		xmlHttpmin = new ActiveXObject("Microsoft.XMLHTTP");
	}else if (window.XMLHttpRequest) {
		xmlHttpmin = new XMLHttpRequest();
	}
	
	xmlHttpmin.onreadystatechange = showGiftMin;
	xmlHttpmin.open("GET", url, true);
	xmlHttpmin.send(null);
	// 每秒刷新一次
	setTimeout("getGiftFromServermin()",1000);
}
function showGiftMin() {
	if (xmlHttpmin.readyState == 4 || xmlHttpmin.readyState == "complete") {
		var goodsArray = JSON.parse(xmlHttpmin.responseText);
		
		for (var i=0;i<goodsArray.length;i++){
			var goodDto = goodsArray[i];
			if (goodDto.TIME == 'undefined' || goodDto.TIME == null || goodDto.TIME == 'null') {
				document.getElementById("time" + goodDto.GOODSID).innerHTML	= "--"
			}	
			else {
				document.getElementById("time" + goodDto.GOODSID).innerHTML	= goodDto.TIME
				document.getElementById("money" + goodDto.GOODSID).innerHTML	= "￥" + goodDto.NOWPRICE
				document.getElementById("who" + goodDto.GOODSID).innerHTML	= goodDto.CURRENTUSER
			}	
		}
	}
}

function goIndex(pinit, phot) {
	init=pinit;
	hot=phot;
	document.forms[0].action="index.pai?init=" + init + "&hot=" + hot;
	document.forms[0].submit();
}
//选择出价 竞拍ID
var xmlHttpPai;
function paipaiId(goodsId) {
	var url = "paimain.pai?goodsId=" + goodsId;
	//alert(url);
	if (window.ActiveXObject) {
		xmlHttpPai = new ActiveXObject("Microsoft.XMLHTTP");
	}else if (window.XMLHttpRequest) {
		xmlHttpPai = new XMLHttpRequest();
	}

	xmlHttpPai.onreadystatechange = showGiftPai;
	
	xmlHttpPai.open("GET", url, true);
	xmlHttpPai.send(null);
}

function showGiftPai() {
	if (xmlHttpPai.readyState == 4 || xmlHttpPai.readyState == "complete") {
		var test = xmlHttpPai.responseText;
			if (test != "success") {
				alert(test);
			}	
	}
}
